#!/bin/bash

# Remove data from Elasticsearch
removeData() {
    curl -s -XPOST 'http://localhost:9200/tai-article/_delete_by_query?conflicts=proceed' -H 'Content-Type: application/json' -d"
{
    \"query\": {
        \"term\": {
            \"_spider_name.keyword\": \"$1\"
        }
    }
}
" | jq -r -c ."deleted" | xargs echo "Deleted $1 articles: "
    # | xargs echo "Deleted $1 articles: "
}

removeData "tass"
removeData "spaceflightnow-mission"
removeData "spacenews"
removeData "satnews"
removeData "satnews-full"
removeData "satellite-today"
removeData "satellite-today-full"
removeData "neoesa-news-full"
removeData "custom-urls"
removeData "cneos-news"